Fix repair of corrupt BlobSizes.sql and mount tolerance#2008
Draft
tyrielv wants to merge 1 commit into
Draft
Conversation
The repair job for BlobSizes.sql was unable to delete the corrupt database file on Windows because SQLite connection pooling kept the file handle open after the integrity check in HasIssue(). Two fixes: 1. SqliteDatabase.HasIssue: Use Pooling=False for integrity check connections so file handles are released immediately on dispose, allowing repair to delete the corrupt file. 2. BlobSizes.Initialize: Tolerate corrupt databases by catching SQLITE_CORRUPT and SQLITE_NOTADB errors, deleting the corrupt file (and WAL/SHM sidecars), and recreating a fresh database. This provides defense-in-depth since BlobSizes is a cache. Also remove SkipInCI from RepairFixesCorruptBlobSizesDatabase and add an assertion that repair actually cleans up the corrupt folder. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
gvfs repair --confirmfailing to delete corrupt BlobSizes.sql on Windows, and add defense-in-depth so mount tolerates corruption.Stacked on #1997
Root Cause
SqliteDatabase.HasIssue()opened a pooled SQLite connection for the integrity check. On Windows, disposing the connection returned the handle to the pool but kept the file locked. When repair tried to delete the corrupt folder,TryDeleteFolderfailed silently (repair still exited 0). The corrupt file remained, causing mount to crash with a broken pipe.Changes
SqliteDatabase.HasIssue— UsePooling=Falsefor integrity-check connections so handles are released on dispose.BlobSizes.Initialize— CatchSQLITE_CORRUPT/SQLITE_NOTADB, callClearAllPools(), delete corrupt DB + WAL/SHM sidecars, recreate fresh. BlobSizes is a cache, so recreation is safe.SqliteErrorCodes.cs— New constants for SQLite result codes.[SkipInCI]fromRepairFixesCorruptBlobSizesDatabase, add assertion that repair deletes the blob sizes folder.